<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.studentmanagement.model.User" %>
<%
    // 检查用户是否已登录
    User user = (User) session.getAttribute("user");
    if (user == null) {
        response.sendRedirect(request.getContextPath() + "/login");
        return;
    }
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加学生 - 学生管理系统</title>
    <link rel="stylesheet" href="<%= request.getContextPath() %>/css/style.css">
</head>
<body>
    <div class="dashboard">
        <header class="header">
            <h1>学生管理系统</h1>
            <div class="user-info">
                欢迎, <%= user.getUsername() %> | <a href="<%= request.getContextPath() %>/logout">退出</a>
            </div>
        </header>
        
        <nav class="sidebar">
            <ul>
                <li><a href="<%= request.getContextPath() %>/student" class="active">学生管理</a></li>
                <li><a href="<%= request.getContextPath() %>/course">课程管理</a></li>
                <li><a href="<%= request.getContextPath() %>/enrollment">选课管理</a></li>
                <li><a href="<%= request.getContextPath() %>/dashboard.jsp">返回控制面板</a></li>
            </ul>
        </nav>
        
        <main class="content">
            <h2>添加学生</h2>
            
            <% if (request.getAttribute("error") != null) { %>
                <div class="error-message">
                    <%= request.getAttribute("error") %>
                </div>
            <% } %>
            
            <form action="<%= request.getContextPath() %>/student/add" method="post" class="form">
                <div class="form-group">
                    <label for="name">姓名:</label>
                    <input type="text" id="name" name="name" required>
                </div>
                
                <div class="form-group">
                    <label for="gender">性别:</label>
                    <select id="gender" name="gender" required>
                        <option value="男">男</option>
                        <option value="女">女</option>
                    </select>
                </div>
                
                <div class="form-group">
                    <label for="birthDate">出生日期:</label>
                    <input type="date" id="birthDate" name="birthDate" required>
                </div>
                
                <div class="form-group">
                    <label for="address">地址:</label>
                    <input type="text" id="address" name="address">
                </div>
                
                <div class="form-group">
                    <label for="phone">电话:</label>
                    <input type="text" id="phone" name="phone">
                </div>
                
                <div class="form-group">
                    <label for="email">邮箱:</label>
                    <input type="email" id="email" name="email">
                </div>
                
                <div class="form-group">
                    <label for="enrollmentDate">入学日期:</label>
                    <input type="date" id="enrollmentDate" name="enrollmentDate" required>
                </div>
                
                <div class="form-group">
                    <label for="major">专业:</label>
                    <input type="text" id="major" name="major" required>
                </div>
                
                <div class="form-group">
                    <label for="status">状态:</label>
                    <select id="status" name="status" required>
                        <option value="在读">在读</option>
                        <option value="休学">休学</option>
                        <option value="毕业">毕业</option>
                        <option value="退学">退学</option>
                    </select>
                </div>
                
                <div class="form-group">
                    <button type="submit" class="btn">保存</button>
                    <a href="<%= request.getContextPath() %>/student" class="btn btn-secondary">取消</a>
                </div>
            </form>
        </main>
        
        <footer class="footer">
            <p>&copy; 2023 学生管理系统. All rights reserved.</p>
        </footer>
    </div>
</body>
</html>

